/*
 * 定时检查我的预约客户提醒
 */
$(function() {
	var remindNum = 0;
	var remindUrl = $('#remindUrl').attr("href");
	var remindListUrl = $('#remindListUrl').attr("href");

	$.getJSON(remindUrl, function(json){
		remindNum = json;
		$("#remind").popover('destroy');
		$("#remind").popover({
			placement: 'top',
			title: '预约提醒',
			html:true,
			content: '<div style="color: black">您当前有 <span style="color: red">'+remindNum+'</span> 条预约回访<br><br><a href="'+remindListUrl+'" onclick="addTab($(this));" target="mainFrame"  style="color: #4b4dff">查看预约回访</a></div>',
			delay: {show: 500, hide: 100}
		}).popover('hide');
		$('#remind').on('show.bs.popover', function () {
			//$('#remind').addClass("btn-success");
			$('#remind').css("color","green");
		});
		$('#remind').on('hide.bs.popover', function () {
			//$('#remind').removeClass("btn-success");
			$('#remind').css("color","");
		});
		if(remindNum>0){
			$("#remind").popover('show');
			//30秒后隐藏弹出框
			setTimeout(function(){$("#remind").popover('hide');},30*1000);
		}
	});

	var handler = function(){

		$.getJSON(remindUrl, function(json){
			remindNum = json;
		});

		if(remindNum>0){
			$("#remind").popover('destroy');
			$("#remind").popover({
				placement: 'top',
				title: '预约提醒',
				html:true,
				content: '<div style="color: black">您当前有 <span style="color: red">'+remindNum+'</span> 条预约回访<br><br><a href="'+remindListUrl+'" onclick="addTab($(this));" target="mainFrame"  style="color: #4b4dff">查看预约回访</a></div>',
				delay: {show: 500, hide: 100}
			}).popover('hide');
			$('#remind').on('show.bs.popover', function () {
				//$('#remind').addClass("btn-success");
				$('#remind').css("color","green");
			});
			$('#remind').on('hide.bs.popover', function () {
				//$('#remind').removeClass("btn-success");
				$('#remind').css("color","");
			});
			$("#remind").popover('show');
			//30秒后隐藏弹出框
			setTimeout(function(){$("#remind").popover('hide');},30*1000);
		}
	}
	setInterval(handler , 10*60*1000);

});
